#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

#define N 155

// #define TEST

const int LARGE_NUMBER = 11111;

typedef struct _node {
	_node *next;
	int id;
};

_node vect[ N ];
int n, p, root, ans, f[ N ][ N ];

void initialize(int n)
{
	for (int i = 1; i <= n; i ++)
	{
		vect[i].id = 0;
		vect[i].next = NULL;
	}
}

void insert(int v, int u)
{
	_node *p;
	p = new _node;
	p->id = u;
	p->next = vect[v].next;
	vect[v].next = p;
	vect[v].id ++; 
}

void del(_node *p)
{
	if (p == NULL) return ;
	del(p->next);
	delete p;
}

void clear(int n)
{
	for (int i = 1; i <= n; i ++)
	{
		del(vect[i].next);
		vect[i].next = NULL;
	}
}


void init()
{
	int s, t;
	int flag[n+1];
	memset(flag, false, sizeof(flag));
	for (int i = 1; i < n; i ++)
	{
		scanf("%d %d", &s, &t);
		insert(s, t);
		flag[t] = true;
	}
	t = 1;
	while (flag[t]) t ++;
	root = t;
}

void output()
{
	printf("%d\n", ans);
}

void DFS(int now)
{
	_node *q = vect[now].next;
	int tmp;
	for (int i = 0; i <= p; i ++) f[now][i] = LARGE_NUMBER;
	f[now][1] = vect[now].id; 
	q = vect[now].next;
	while (q != NULL)
	{
		DFS(q->id);
		for (int j = p-1; j >= 0; j --)
		{
			if (f[now][j] < LARGE_NUMBER)
			{
				for (int k = 1; k < p; k ++)
				{
					if (f[q->id][k] < LARGE_NUMBER)
					{
						tmp = f[now][j] + f[q->id][k] -1;
						if (tmp < f[now][j+k])
						{
							f[now][j+k] = tmp;
						}
					}
				}
			}
		}
		q = q->next;;
	}
}

void dp()
{
	DFS(root);
	
#ifdef TEST
	for (int i = 1; i <= n; i ++)
	{
		for (int j = 1; j <= p; j ++)
		{
			cout << f[i][j] << " ";
		}
		cout << endl;
	}
#endif
	
	ans = f[root][p];
	for (int i = 1; i <= n; i++)
	{
		if (f[i][p] < ans) ans = f[i][p]+1;
	}
}

int main()
{
	while (scanf("%d %d", &n, &p) != EOF)
	{
		initialize(n);
		init();
		dp();
		output();
		clear(n);
	}
	return 0;
}